In [1]:
colores = { "amarillo":"yellow", "azul":"blue", "verde":"green" }
In [2]:
colores['amarillo']
Out[2]:
In [4]:
colores.get('negro','no se encuentra')
Out[4]:
In [7]:
'amarillo' in colores
Out[7]:
In [9]:
colores.keys()
Out[9]:
In [10]:
colores.values()
Out[10]:
In [11]:
colores.items()
Out[11]:
In [13]:
for c in colores:
print(colores[c])
In [16]:
for c,v in colores.items():
print(c,v) # clave, valor
In [17]:
colores.pop("amarillo","no se ha encontrado")
Out[17]:
In [18]:
colores
Out[18]:
In [19]:
colores.pop("negro","no se ha encontrado")
Out[19]:
In [20]:
colores
Out[20]:
In [21]:
colores.clear()
In [22]:
colores
Out[22]: